package edu.msg.jthr.backend.model;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

@Entity
@Table(name = "USER")
public class User extends BaseEntity {

	private static final long serialVersionUID = 1L;

	@NotNull
	@Column(name = "FIRSTNAME")
	private String firstName;

	@NotNull
	@Column(name = "LASTNAME")
	private String lastName;

	// valid phone number from Romania or Germany
	@Column(name = "TEL_NUMBER")
	private String telNumber;

	// valid phone number from Romania or Germany
	@NotNull
	@Column(name = "TEL_MOBILE_NUMBER")
	private String telMobileNumber;

	// valid internal mail address only
	@NotNull
	@Column(name = "MAIL")
	private String mail;

	@Column(name = "FUNCTION_AT_COMP")
	private String functionAtComp;

	@Column(name = "DESCRIPTION")
	private String description;

	/*
	 * generated: first 5 letters from lastname + firstname's first character if
	 * duplicate username, then one more charater from firstname
	 */
	@NotNull
	@Column(name = "USERNAME")
	private String userName;

	@NotNull
	@Column(name = "PASSWORD")
	private String password;

	@OneToMany(mappedBy = "user")
	private List<UserGroup> userGroups;

	public User() {
	}

	public User(long id, String uuid, String firstName, String lastName,
			String telNumber, String telMobileNumber, String mail,
			String functionAtComp, String description, String userName,
			String password, List<UserGroup> userGroups) {
		super(id, uuid);
		this.firstName = firstName;
		this.lastName = lastName;
		this.telNumber = telNumber;
		this.telMobileNumber = telMobileNumber;
		this.mail = mail;
		this.functionAtComp = functionAtComp;
		this.description = description;
		this.userName = userName;
		this.password = password;
		this.userGroups = userGroups;
	}

	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public String getTelNumber() {
		return telNumber;
	}

	public void setTelNumber(String telNumber) {
		this.telNumber = telNumber;
	}

	public String getTelMobileNumber() {
		return telMobileNumber;
	}

	public void setTelMobileNumber(String telMobileNumber) {
		this.telMobileNumber = telMobileNumber;
	}

	public String getMail() {
		return mail;
	}

	public void setMail(String mail) {
		this.mail = mail;
	}

	public String getFunctionAtComp() {
		return functionAtComp;
	}

	public void setFunctionAtComp(String functionAtComp) {
		this.functionAtComp = functionAtComp;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public List<UserGroup> getUserGroups() {
		return userGroups;
	}

	public void setUserGroups(List<UserGroup> userGroups) {
		this.userGroups = userGroups;
	}

	@Override
	public String toString() {
		return "[" + firstName + " , " + lastName + " , " + telNumber + ","
				+ telMobileNumber + "," + mail + "," + functionAtComp + ","
				+ description + "," + userName + "]";
	}
}
